/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.articles.importFromLn.articleImport;

/**
 *
 * @author Martin Řehánek (rehan@mzk.cz)
 */
public class Periodical {

    //TODO: vyresit problem s kodovanim, kdyz se jmeno nacita z properties
    private static final String NAME= "Lidové noviny";
    private static final String UUID_PREFIX = "uuid:";
    private final String name;
    private final String issn;
    private final String pid;
    private final String uuid;

    public Periodical(String name, String issn, String pid) {
        this.name = name;
        this.issn = issn;
        this.pid = pid;
        this.uuid = uuidFromPid(pid);
    }

    /**
     * @return the name
     */
    public String getName() {
        //TODO
        //return name;
        return NAME;
    }

    /**
     * @return the issn
     */
    public String getIssn() {
        return issn;
    }

    public String getPid() {
        return pid;
    }

    public String getUuid() {
        return uuid;
    }

    private String uuidFromPid(String pid) {
        if (!pid.startsWith(UUID_PREFIX) || pid.length() != (36 + UUID_PREFIX.length())) {
            throw new IllegalArgumentException("'" + pid + "' is not pid");
        } else {
            return pid.substring(UUID_PREFIX.length(), pid.length());
        }
    }
}
